import { Component ,Injectable} from '@angular/core';
import { NavController ,NavParams} from 'ionic-angular';
import $ from 'jquery';
import  'rxjs/add/operator/toPromise';
@Component({
  selector: 'page-me',
  templateUrl: 'me.html'
})

@Injectable()
export class MePage {
  msg;
  id:Number;
  constructor(public navCtrl: NavController,public param:NavParams) {
    console.log('param',this.param);
  }

   async test(){
     this.msg = await this.getAsync();
     console.log('msg',this.msg);
  }

  getAsync() :Promise<string>{
    return  new Promise((resolve, reject) => {
      /*setTimeout(() => {
        resolve('Promise with AsyncPipe complete!');
      }, 200);*/

      $.ajax({
        url:'',
        type:'get',
        success:(res)=>{

          resolve('ajax  success');
        },
        error:(error)=>{

          resolve('ajax  error');
        }
      });

    });
  }

}

